﻿using IRepositoryDal;
using Microsoft.EntityFrameworkCore;
using RepositoryEntity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RepositoryDal
{
    /// <summary>
    /// 部门数据库访问层
    /// </summary>
    public class DepartmentInfoDal : BaseDal<DepartmentInfo>, IDepartmentInfoDal
    {
        //数据库上文
        RepositoryDbContext _DbContext;

        public DepartmentInfoDal(RepositoryDbContext DbContext):base(DbContext)
        {
            _DbContext = DbContext;
        }

        /// <summary>
        /// 添加部门
        /// </summary>
        /// <param name="departmentInfo"></param>
        /// <returns></returns>
        //public bool AddDepartmentInfo(DepartmentInfo departmentInfo)
        //{
        //    _DbContext.DepartmentInfo.Add(departmentInfo);
        //    int index = _DbContext.SaveChanges();
        //    if (index > 0)
        //    {
        //        return true;
        //    }
        //    else
        //    {
        //        return false;
        //    }
        //}

        //public void Delete(List<DepartmentInfo> deleteEntityInfos)
        //{
        //    throw new NotImplementedException();
        //}



        /// <summary>
        /// 根据id获取部门信息
        /// </summary>
        /// <param name="departmentInfoId">部门id</param>
        /// <returns></returns>
        //public DepartmentInfo GetDepartmentInfo(string departmentInfoId)
        //{
        //    DepartmentInfo departmentInfo = _DbContext.DepartmentInfo.FirstOrDefault(u => u.ID == departmentInfoId);
        //    return departmentInfo;
        //}

        /// <summary>
        /// 获取部门集合
        /// </summary>
        /// <returns></returns>
        //public List<DepartmentInfo> GetDepartmentInfos()
        //{
        //    return _DbContext.DepartmentInfo.ToList();
        //}

        //public DbSet<DepartmentInfo> GetDepartmentInfosDb()
        //{
        //    return _DbContext.DepartmentInfo;
        //}

        //public DbSet<DepartmentInfo> GetLeaderSelectDb()
        //{
        //    return _DbContext.DepartmentInfo;
        //}

        /// <summary>
        /// 更新部门
        /// </summary>
        /// <param name="departmentInfo"></param>
        /// <returns></returns>
        //public bool UpdateDepartmentInfo(DepartmentInfo departmentInfo)
        //{
        //    DepartmentInfo entity = _DbContext.DepartmentInfo.FirstOrDefault(u=> u.ID == departmentInfo.ID);
        //    entity.DepartmentName = departmentInfo.DepartmentName;
        //    int index = _DbContext.SaveChanges();
        //    if (index > 0)
        //    {
        //        return true;
        //    }
        //    else
        //    {
        //        return false;
        //    }
        //}
    }
}
